#!/usr/bin/perl

open MACHINE_FILE, @ARGV[0] or die $!; #list of vms

@machine_list; #array storing a copy of vm list
@IP_list;
$machine_index = 0;
while($line = <MACHINE_FILE>) {
  chomp($line);
  if(rindex($line, "#") == -1){ #ingore the commented ones
    @items = split(" ", $line);  
    $IP_list[$machine_index] = $items[0];
    $machine_list[$machine_index] = $items[1];
    $machine_index ++;
  }
}

for($i = 0; $i < @machine_list; $i++) {
  $src_command = "ssh ".$machine_list[$i]." /root/monalytics/test/helloworlds/packetFilter/packetFilter eth0 ".$IP_list[$i]." &";
  print $src_command."\n";
  system($src_command);
}
